from Login import settings
from celery import Celery
from django.core.mail import send_mail
import time
import os
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE","Login.settings")
django.setup()

app = Celery('celery_tasks.tasks', broker='redis://:1@192.168.43.13:6379/0')

@app.task
def send_active_email(to_email, username, token):
    subject = '日圆生鲜欢迎你'  # 邮件标题
    message = 'how are you'  # 邮件正文
    sender = settings.EMAIL_FROM  # 发件人
    receiver = [to_email]  # 收件人
    html_message = """
                    <h1>%s  恭喜您成为日圆生鲜注册会员</h1><br/><h3>请您在1小时内点击以下链接进行账户激 活，领取漂亮女朋友</h3><a href="http://127.0.0.1:8000/user/active/%s">http://127.0.0.1:8000/user/active/%s</a>
                    """ % (username, token, token)
    send_mail(subject, message, sender, receiver, html_message=html_message)
    time.sleep(3)
